import { http } from "@/utils/http";
import { formatToken } from "@/utils/auth";
import type { ApiResponse } from "./user";

export interface QiniuUploadToken {
  uploadToken: string;
  domain: string;
  uploadUrl: string;
}

const authApi = {
  qiniu() {
    return http.request<ApiResponse<QiniuUploadToken>>("get", "/auth/qiniu");
  },
  qiniuPartial(partialToken: string) {
    return http.request<ApiResponse<QiniuUploadToken>>(
      "get",
      "/auth/verification/qiniu",
      {},
      {
        headers: {
          Authorization: formatToken(partialToken)
        }
      }
    );
  }
};

export default authApi;
